home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
embedded
/
mcu332
/
332equ.arc
/
DEF.MAC
< prev
next >
Wrap
Text File
|
1990-03-12
|
8KB
|
196 lines
****************************************************************************
* $RCSfile: def.mac $
* $Revision: 1.1 $
* $Date: 90/03/12 13:46:02 $
*
* -------------------------------------------------------------
* Module Name: DEF - Define Symbols Macro
* -------------------------------------------------------------
*
* Description:
* 1. This file contains EQUates and a DEF macro for use with
* MCU's that have internal registers and the bits in those
* registers. By INCLUDE'ing this file with the specific MCU
* equate file(s), mnemonic symbols are defined for the
* internal registers and bits.
* 2. The DEF macro controls how these mnemonic symbols are
* defined. By channeling all symbol definitions through the
* DEF macro, changes made to the DEF macro will affect ALL
* symbol definitions upon re-assembly! See the DEF macro for
* more details.
*
* Notes:
* 1. Motorola reserves the right to make changes to this file.
* Although this file has been carefully reviewed and is
* believed to be reliable, Motorola does not assume any
* liability arising out of its use. This code may be freely
* used and/or modified at no cost or obligation to the user.
* 2. All descriptions are WORD values unless stated otherwise.
* 3. This file was made for use with the Motorola Development
* Systems M68000 Family Structured Assembler for MS-DOS,
* known as M68MASM.
* 4. To use this file, either use an INCLUDE statement or just
* merge this file and the appropriate MCU register equate
* file(s) into your source code file. Consult your assem-
* bler's user's manual for the details specific to your
* situation.
* 5. The latest version of this file is maintained on the
* Motorola FREEWARE Bulletin Board, 512/891-FREE (512/891-
* 3733). It operates continuously (except for maintenance)
* at 1200-2400 baud, 8-bits, no parity. Download the
* archive file <mcu>EQU.ARC to get all the files, where
* <mcu> represents the processor type desired, i.e.
* 332EQU.ARC for MC68332, etc.
*
****************************************************************************
* Defines for Bit Definition Types (see DEF macro):
*
BIT$NUM EQU 1 Bit numbers (0-15)
BIT$VAL EQU 2 Bit position values ($0000-$8000)
BIT$BOTH EQU BIT$NUM+BIT$VAL Both bit numbers and values
*
BIT$CODE EQU BIT$BOTH Bit definitions for this assembly!
* NOTE: Change BIT$CODE above to control bit definition types!
* Bit Number Equates
*
.B15 EQU 15
.B14 EQU 14
.B13 EQU 13
.B12 EQU 12
.B11 EQU 11
.B10 EQU 10
.B9 EQU 9
.B8 EQU 8
.B7 EQU 7
.B6 EQU 6
.B5 EQU 5
.B4 EQU 4
.B3 EQU 3
.B2 EQU 2
.B1 EQU 1
.B0 EQU 0
* Bit Value Equates
*
_B15 EQU 1<<.B15
_B14 EQU 1<<.B14
_B13 EQU 1<<.B13
_B12 EQU 1<<.B12
_B11 EQU 1<<.B11
_B10 EQU 1<<.B10
_B9 EQU 1<<.B9
_B8 EQU 1<<.B8
_B7 EQU 1<<.B7
_B6 EQU 1<<.B6
_B5 EQU 1<<.B5
_B4 EQU 1<<.B4
_B3 EQU 1<<.B3
_B2 EQU 1<<.B2
_B1 EQU 1<<.B1
_B0 EQU 1<<.B0
* Mask Value Equates
*
MSK16 EQU $FFFF 16-bit mask
MSK15 EQU $7FFF 15-bit mask
MSK14 EQU $3FFF 14-bit mask
MSK13 EQU $1FFF 13-bit mask
MSK12 EQU $0FFF 12-bit mask
MSK11 EQU $07FF 11-bit mask
MSK10 EQU $03FF 10-bit mask
MSK9 EQU $01FF 9-bit mask
MSK8 EQU $00FF 8-bit mask
MSK7 EQU $007F 7-bit mask
MSK6 EQU $003F 6-bit mask
MSK5 EQU $001F 5-bit mask
MSK4 EQU $000F 4-bit mask
MSK3 EQU $0007 3-bit mask
MSK2 EQU $0003 2-bit mask
MSK1 EQU $0001 1-bit mask
****************************************************************************
* Define Bit Macro:
* Syntax: DEF <name>,<value>[,<field size>[,<reg size>]]
*
* where: <name> is the bit name to be defined.
* <value> is the bit number associated with <name>;
* must be entered as "Bn", where "n" = 0-15.
* <field size> is the optional bit field size starting with
* <value> which must be the least significant
* bit (LSB) of the field. When this parameter
* is present, only the bit field and bit number
* labels are defined.
* <reg size> is the optional size of the register, entered
* as "MSK8" for BYTE sized operands (8-bit).
* The default value is "MSK16" for WORD sized
* operands.
* Action:
* Defines bit number, bit value, or bit field labels based on the
* <name> label and the value of BIT$CODE (defined above).
* Label Key:
* Period prefix (.) denotes bit number label.
* Underscore prefix (_) denotes bit value label.
* Underscore suffix (_) denotes bit field label.
* Underscore MSK suffix (_MSK) denotes bit field mask label.
* Underscore NMSK suffix (_NMSK) denotes not-bit field mask label.
* Label Examples:
* .NAME = bit number label, i.e. 0-15
* _NAME = bit value label, i.e. $0000-$8000
* NAME_ = bit field value label, i.e. $0100 (LSB of field)
* NAME_MSK = bit field mask label, i.e. $0700 (3-bit field)
* NAME_NMSK = bit field not-mask label, i.e. $F8FF (3-bit field)
*
* Notes:
* 1. The "SET" directive is used here instead of the "EQU" directive
* to allow multiple definitions of the same bit labels that are
* used for multiple registers, each with the same values.
* 2. If the user changes the predefined label rules per the Label Key
* above, it is their responsibility to ensure duplicate labels with
* different bit values do not occur!
*
DEF MACRO
IFC "","\3"
IFNE BIT$CODE&BIT$NUM
.\1 SET .\2
ENDC
IFNE BIT$CODE&BIT$VAL
_\1 SET _\2
ENDC
ENDC
IFNC "","\3"
.\1 SET .\2
\1_ SET _\2
\1_MSK SET (MSK\3)<<.\2
IFC "","\4"
\1_NMSK SET (-\1_MSK-1)&MSK16
ENDC
IFNC "","\4"
\1_NMSK SET (-\1_MSK-1)&\4
ENDC
ENDC
ENDM
IFNE 0 ------- don't assemble unless needed --------
DEF NBL0,B0,4 . nibble 0
DEF NBL1,B4,4 . nibble 1
DEF NBL2,B8,4 . nibble 2
DEF NBL3,B12,4 . nibble 3
DEF HNBL0,B0,2 . half nibble 0
DEF HNBL1,B2,2 . half nibble 1
DEF HNBL2,B4,2 . half nibble 2
DEF HNBL3,B6,2 . half nibble 3
DEF HNBL4,B8,2 . half nibble 4
DEF HNBL5,B10,2 . half nibble 5
DEF HNBL6,B12,2 . half nibble 6
DEF HNBL7,B14,2 . half nibble 7
ENDC